USE [usuarios]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tbl_usuario_perfil_tbl_perfil]') AND parent_object_id = OBJECT_ID(N'[dbo].[tbl_usuario_perfil]'))
ALTER TABLE [dbo].[tbl_usuario_perfil] DROP CONSTRAINT [FK_tbl_usuario_perfil_tbl_perfil]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_tbl_usuario_perfil_tbl_usuario]') AND parent_object_id = OBJECT_ID(N'[dbo].[tbl_usuario_perfil]'))
ALTER TABLE [dbo].[tbl_usuario_perfil] DROP CONSTRAINT [FK_tbl_usuario_perfil_tbl_usuario]
GO

USE [usuarios]
GO

/****** Object:  Table [dbo].[tbl_usuario_perfil]    Script Date: 06/29/2011 09:13:59 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbl_usuario_perfil]') AND type in (N'U'))
DROP TABLE [dbo].[tbl_usuario_perfil]
GO

USE [usuarios]
GO

/****** Object:  Table [dbo].[tbl_usuario_perfil]    Script Date: 06/29/2011 09:13:59 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[tbl_usuario_perfil](
	[upe_usu_id] [varchar](20) NOT NULL,
	[upe_per_id] [varchar](10) NOT NULL,
	[upe_estado] [int] NOT NULL,
 CONSTRAINT [PK_tbl_usuario_perfil] PRIMARY KEY CLUSTERED 
(
	[upe_usu_id] ASC,
	[upe_per_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[tbl_usuario_perfil]  WITH CHECK ADD  CONSTRAINT [FK_tbl_usuario_perfil_tbl_perfil] FOREIGN KEY([upe_per_id])
REFERENCES [dbo].[tbl_perfil] ([per_id])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[tbl_usuario_perfil] CHECK CONSTRAINT [FK_tbl_usuario_perfil_tbl_perfil]
GO

ALTER TABLE [dbo].[tbl_usuario_perfil]  WITH CHECK ADD  CONSTRAINT [FK_tbl_usuario_perfil_tbl_usuario] FOREIGN KEY([upe_usu_id])
REFERENCES [dbo].[tbl_usuario] ([usu_id])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[tbl_usuario_perfil] CHECK CONSTRAINT [FK_tbl_usuario_perfil_tbl_usuario]
GO

